package com.winning.pmph.utils;

import com.winning.pmph.entity.History;
import com.winning.pmph.entity.User;
import com.winning.pmph.mapper.HistoryMapper;
import com.winning.pmph.service.UserService;

/**
 * @author 吴笛
 * @date 2020/12/2
 */
public class HistoryUtils {
    private static UserService userService = ApplicationContextUtil.getBean(UserService.class);
    private static HistoryMapper historyMapper = ApplicationContextUtil.getBean(HistoryMapper.class);

    public static History save(String knowledgeId, String knowledgeName, int operate, int result) {
        String username = PMPHAppUtil.getCurrentUserEnName();
        User user = userService.getUserByUserName(username);
        History history = new History();
        history.setKnowledgeId(knowledgeId);
        history.setKnowledgeName(knowledgeName);
        history.setHandlerId(user.getId());
        history.setOperate(operate);
        history.setOresult(result);
        return historyMapper.saveBean(history);
    }
}
